package com.sushi.enums;

import com.sushi.utils.StringUtil;

/**
 * @author wywei
 */
public class Type {


    public enum Trade {


        COMMUNITY("0", "社区货币")
        ,WECHAT("1", "微信")
        ,ZFB("2", "支付宝")
        ,OTO("3", "物物交换")
        ,FREE("4", "免费")
        ,DIY("5", "自定义")
        ;

        private final String code;
        private final String value;
        private Trade(String code, String value) {
            this.code = code;
            this.value = value;
        }
        public static String parse(String code) {
            for (Trade element : Trade.values()) {
                if (element.code.equals(code)) {
                    return element.value;
                }
            }
            return null;
        }
        public String getCode() {
            return code;
        }
        public String getValue() {
            return value;
        }

    }

    public enum Tag {

        GAME("1", "游戏")
        ,COMMODITY("2", "商品")
        ,MANUAL("3", "图鉴")
        ,POST("4", "交流帖")
        ,ACTIVITY("5", "活动")
        ;

        private final String code;
        private final String value;
        private Tag(String code, String value) {
            this.code = code;
            this.value = value;
        }
        public static String parse(String code) {
            for (Tag element : Tag.values()) {
                if (element.code.equals(code)) {
                    return element.value;
                }
            }
            return null;
        }
        public String getCode() {
            return code;
        }
        public String getValue() {
            return value;
        }
    }

    public enum Object {

        GAME("1", "游戏")
        ,COMMODITY("2", "商品")
        ,MANUAL("3", "图鉴")
        ,POST("4", "交流贴")
        ,ACTIVITY("5", "活动")
        ;
        private final String code;
        private final String value;
        private Object(String code, String value) {
            this.code = code;
            this.value = value;
        }
        public String getCode() {
            return code;
        }
        public String getValue() {
            return value;
        }
        public static String parse(String code) {
            for (Object element : Object.values()) {
                if (StringUtil.equals(element.code, code)) {
                    return element.value;
                }
            }
            return null;
        }
    }

    public enum Commodity {

        GAME_ACCOUNT("1", "游戏账号")
        ,GAME_EQUIPMENTS("2", "游戏装备")
        ,GAME_TOOL("3", "游戏外设")
        ,OTHER("4", "其他内容")
        ;
        private final String code;
        private final String value;
        private Commodity(String code, String value) {
            this.code = code;
            this.value = value;
        }
        public String getCode() {
            return code;
        }
        public String getValue() {
            return value;
        }
        public static String parse(String code) {
            for (Commodity element : Commodity.values()) {
                if (StringUtil.equals(element.code, code)) {
                    return element.value;
                }
            }
            return null;
        }
    }


    public enum Post {

        HELP("1", "求助")
        ,TEACH("2", "教程")
        ,DISCUSS("3", "讨论")
        ,SHARE("4", "分享")
        ,OTHER("5", "其他")
        ;
        private final String code;
        private final String value;
        private Post(String code, String value) {
            this.code = code;
            this.value = value;
        }
        public String getCode() {
            return code;
        }
        public String getValue() {
            return value;
        }
        public static String parse(String code) {
            for (Post element : Post.values()) {
                if (StringUtil.equals(element.code, code)) {
                    return element.value;
                }
            }
            return null;
        }
    }

    public enum UserGender {

        SECRET("0", "保密")
        ,MALE("1", "男")
        ,FEMALE("2", "女")
        ;
        private final String code;
        private final String value;
        private UserGender(String code, String value) {
            this.code = code;
            this.value = value;
        }
        public String getCode() {
            return code;
        }
        public String getValue() {
            return value;
        }
        public static String parse(String code) {
            for (UserGender element : UserGender.values()) {
                if (StringUtil.equals(element.code, code)) {
                    return element.value;
                }
            }
            return null;
        }
    }

    public enum UserIdentity {

        NORMAL_USER("0", "普通用户")
        ,ADMIN("1", "管理员")
        ,SUPER_ADMIN("3", "超级管理员")
        ;
        private final String code;
        private final String value;
        private UserIdentity(String code, String value) {
            this.code = code;
            this.value = value;
        }
        public String getCode() {
            return code;
        }
        public String getValue() {
            return value;
        }
        public static String parse(String code) {
            for (UserIdentity element : UserIdentity.values()) {
                if (StringUtil.equals(element.code, code)) {
                    return element.value;
                }
            }
            return null;
        }
    }

}
